const webpack = require('webpack')
const path = require('path')

function resolve (dir) {
    return path.join(__dirname, '..', dir)
}

module.exports = {
    publicPath: './',
    assetsDir: 'static',
    outputDir: 'dist',
    indexPath: 'index.html',
    pages: {
        index: {
            entry: 'src/main.js',
            template: 'public/index.html',
            filename: 'index.html',
            title: 'Index Page',
            chunks: ['chunk-vendors','chunk-common','index'],
            favicon: 'public/logo.ico'
        },
        // 当使用只有入口的字符串格式时，
        // 模板会被推导为 `public/subpage.html`
        // 并且如果找不到的话，就回退到 `public/index.html`。
        // 输出文件名会被推导为 `subpage.html`。
        // subpage: 'src/subpage/main.js'
    },
    lintOnSave: true,
    productionSourceMap: false,
    configureWebpack: {
        plugins: [
            new webpack.ProvidePlugin({
                $:"jquery",
                jQuery:"jquery",
                "window.jQuery":"jquery",
                moment:"moment",
                axios:"axios",
                echarts:'echarts'
            })
        ]
    },
    chainWebpack: config => {
        config.module
        .rule('swf')
        .test(/\.swf$/)
        .use('url-loader')
        .loader('url-loader');

        config.module
        .rule('compile')
            .test(/\.js$/)
            .include
            .add(resolve('src/assets/js'))
            .add(resolve('node_modules/webpack-dev-server/client'))
            .end()
            .use('babel')
            .loader('babel-loader');   
    },
    css: {
        modules: false,
        extract: true,
        sourceMap: false,
        loaderOptions: {
            
        }
    },
    devServer: {
        host: 'localhost',
        port: 8080,
        https: false,
        hotOnly: false,
        open: true,
        // proxy: {
        //     '/api/*': {
        //         target: 'http://192.168.31.48:9091',
        //         changeOrigin: true,
        //         ws: true,
        //         secure: false
        //     }
        // }
    },
    pluginOptions: {

    }
}